package me.softwareengineer.guice.rendering.parser.imp.plainText;

import java.io.Reader;

import com.google.inject.Inject;

import me.softwareengineer.guice.rendering.domain.DOM;
import me.softwareengineer.guice.rendering.domain.Syntax;
import me.softwareengineer.guice.rendering.parser.DomGeneratorListener;
import me.softwareengineer.guice.rendering.parser.ParseException;
import me.softwareengineer.guice.rendering.parser.Parser;



/**
 * A Plain Text {@link Parser}. Parses plain text input and produces a DOM tree. 
 * 
 * @author yad.tahir
 * @see Parser
 * @version 1.0
 */

public final class PlainTextParser implements Parser{

	private DomGeneratorListener domGenerator;
	
	/**
	 * Constructs a plain text parser.
	 * 
	 * @param domGenerator the creator of the dom tree. This param will be injected by 
	 * Guice. 
	 * 
	 * @see DomGeneratorListener
	 */
	@Inject
	public PlainTextParser(DomGeneratorListener domGenerator){
		this.domGenerator = domGenerator;
	}
	

	@Override
	public DOM parse(Reader reader) throws ParseException {
		//Parse the content and sent the event to dom generator listener
		//TODO parse the content
		
		//Asks the dom generator to provide the DOM tree based on the passed events
		return domGenerator.getDom();
	}




}
